import {defineStore} from "pinia";

export const useMainStore = defineStore('main', {
    state: () => {
        return {
            testPinia: '欢迎使用Pinia',
            testPinia1: '欢迎使用Pinia1',
            testPinia2: '欢迎使用Pinia2',
            testArr: [1, 2, 3, 4],
            count: 10
        }
    },

    getters: {
        addOne(state) {
            console.log("addOne被调用");
            return state.count + 1;
        }
    },

    actions: {
        changeState() {
            this.testPinia1 = '通过action修改成功';
        }, changeState2(val: string) {
            this.testPinia1 = val;
        }
    }
})